<?php

include '../init.php';

// 加载数据库连接文件
include DIR_CORE.'/MySQLDB.php';

// 接收数据
$pub_id = $rep_pub_id = $_POST['pub_id'];
$rep_content = escapeString($_POST['rep_content']);

// 验证数据
if (empty($rep_content)) {
    jump("./reply.php?pub_id=$pub_id", "内容不能为空！");
}

// 数据入库
session_start();
$rep_user = $_SESSION['userInfo']['user_name'];
$rep_time = time();
$sql = "insert into reply values(null, '$rep_pub_id', '$rep_user', '$rep_content', '$rep_time', default, default)";
$result = my_query($sql);

// 判断执行结果
if ($result) {
    jump("./show.php?pub_id=$pub_id&action=reply", "回贴成功！");
} else {
    jump("./reply.php?pub_id=$pub_id&action=reply", "回贴失败！");
}

include DIR_VIEW.'/show.html';

?>
